import xadmin

from xadmin import views
from .models import Article, Category, Tag


class BaseSetting(object):
    enable_themes = True
    use_bootswatch = True


class GlobalSettings(object):
    site_title = '博客后台系统'
    site_footer = '博客后台系统'


class ArticleAdmin(object):
    list_display = ['title', 'author', 'summary', 'category', 'tag', 'view_nums', 'add_time']
    search_fields = ['title', 'author', 'content','category', 'tag', 'view_nums', 'comment_nums']
    list_filter = ['title', 'author', 'summary', 'category', 'tag', 'view_nums', 'add_time']


class CategoryAdmin(object):
    list_display = ['name', 'add_time']
    search_fields = ['name']
    list_filter = ['name', 'add_time']


class TagAdmin(object):
    list_display = ['name', 'add_time']
    search_fields = ['name']
    list_filter = ['name', 'add_time']


xadmin.site.register(Article, ArticleAdmin)
xadmin.site.register(Category, CategoryAdmin)
xadmin.site.register(Tag, TagAdmin)
xadmin.site.register(views.BaseAdminView, BaseSetting)
xadmin.site.register(views.CommAdminView, GlobalSettings)

